When photographing an object, the object may be partially illuminated and partially shadowed. In such a case, a situation may occur in which on the resultant image, the difference in luminance between the illuminated part and the shadowed part of the object is so significant that it is difficult to identify either of the parts. Therefore, there has been proposed a technique in which it is possible to improve the contrast of an object by compressing a dynamic range according to the Retinex theory (for example, refer to D. J. Jobson, et al., “Properties and Performance of a Center/Surround Retinex”, IEEE Trans. On Image Processing, Vol. 6, No. 3, March 1997).
The Retinex theory is based on an assumption that the human visual system perceives an object based on a reflectance distribution on the surface of the object which is obtained by eliminating an illuminance distribution of illumination light from a distribution of reflected light from the object rather than a distribution of the reflected light. Thus, in the Retinex theory, it is assumed that the following equation holds:I(x,y)=R(x,y)L(x,y)wherein I(x,y) is a luminance value of a pixel (x,y) of the original image, R(x,y) is a reflectance of an object captured at the pixel (x,y) in the original image, and L(x,y) is an illuminance of illumination light at the pixel (x,y).
In this regard, as the illuminance distribution L of illumination light, for example, a smoothed image is used which is obtained by applying a low-pass filter such as a Gaussian filter to the original image. Further, the reflectance R(x,y) of each pixel is determined, for example, by performing calculation of R(x,y)=I(x,y)/L(x,y), and a corrected image is obtained by multiplying the reflectance R(x,y) of each pixel by a constant k (wherein k>1).
When the image includes an edge portion in which the illuminance of illumination light changes abruptly, in order to accurately estimate the illuminance distribution L of the illumination light, it is preferable that a smoothing process is performed with respect to the image such that the edge portion is preserved. When the edge portion is not preserved, a discrepancy may occur between the actual illuminance distribution L of the illumination light and the smoothed image in the edge portion, thus an artifact may occur in the corrected image.
Further, in recent years, due to the development of high-definition image sensors, images with a very large number of pixels have been used. Also with videos, moving images in which the number of pixels per frame is large, such as so-called 4k, are becoming to be used. Therefore, the amount of calculation can preferably be reduced when image correction is performed.
Accordingly, there has been proposed a technique for obtaining, with a small amount of calculation, an illumination light component image in which an artifact does not occur in a gradation correction result (for example, refer to Japanese Laid-open Patent Publication No. 2012-85182). The image processing apparatus disclosed in Japanese Laid-open Patent Publication No. 2012-85182 performs a smoothing process in a state in which an edge is preserved in a reduced image obtained by reducing an input image, and thereby enlarges the resultant image in a state in which the edge is preserved. The image processing apparatus performs, during the enlargement, a filtering process that interpolates pixels and determines a pixel value of an interest pixel, which is a target for the filtering process, based on a weighted addition of pixel values of respective reference pixels. Further, the image processing apparatus sets a weighting factor for the pixel value of each reference pixel based on the difference between the pixel value of the input image corresponding to the interest pixel and the pixel value of each reference pixel and the distance between the interest pixel and each reference pixel after the enlargement.